﻿using NHibernate.Mapping.ByCode;
using FinancePortal.Domain.Model;

namespace FinancePortal.Domain.Mapping
{
    public class VacationScheduleMapping : EntityMapping<VacationSchedule>
    {
        public VacationScheduleMapping()
        {
            Property(x => x.FromDate, m => m.NotNullable(true));
            Property(x => x.ToDate, m => m.NotNullable(true));
            Property(x => x.ResourceId, m => m.NotNullable(true));

            ManyToOne<Resource>(x => x.Resource, m =>
            {
                m.Cascade(Cascade.None);
                m.NotNullable(true);
                m.Column("ResourceId");
                m.Insert(false);
                m.Update(false);
            });

            Property(x => x.DeputyId, m => m.NotNullable(true));

            ManyToOne<Resource>(x => x.Deputy, m =>
            {
                m.Cascade(Cascade.None);
                m.NotNullable(true);
                m.Column("DeputyId");
                m.Insert(false);
                m.Update(false);
            });
        }
    }
}
